package com.example.chat.viewmodel

import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateMapOf
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.ViewModel
import com.example.chat.model.Message
import com.example.featuresdk.model.IconManager
import dagger.hilt.android.lifecycle.HiltViewModel
import okhttp3.internal.toImmutableMap
import java.sql.Timestamp
import javax.inject.Inject

@HiltViewModel
class ChatDetailViewModel @Inject constructor() : ViewModel() {

    /**
     * the current message in the chat
     */
    val chatContent = mutableStateOf("")

    /**
     * the current message type
     */
    val messageType = mutableStateOf(MessageType.None)

    /**
     * the width of the text field for text message
     */
    val textMessageFieldWidthDp = mutableStateOf(270)

    /**
     * the height of the chat type selector box, same as the software keyboard height (TBD)
     */
    val messageTypeSelectorHeightDp = 280

    /**
     * whether or not to show the selector for message type
     */
    val messageTypeSelectorVisible = mutableStateOf(false)

    /**
     * the messages
     */
    val chatMessages = mutableStateListOf<Message>() //mutableListOf<Message>()



    fun sendMessage(){
        chatMessages.add(Message("me","",chatContent.value, Timestamp(System.currentTimeMillis())))
        chatContent.value = ""
        chatMessages.add(Message("","","Received", Timestamp(System.currentTimeMillis())))
    }

    val emojiIcons = IconManager.icons

}

enum class MessageType(){
    Text, Emoji, Voice, Photo, Camera, Video, Location, None, Others
}